package ylkhfzhs.basic.service.impl;
import jakarta.annotation.Resource;
import org.apache.catalina.User;
import ylkhfzhs.basic.global.GlobalEnum;
import ylkhfzhs.basic.service.UserService;
import ylkhfzhs.basic.vo.UserVo;

import java.time.LocalDateTime;

public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public GlobalEnum.ErrorCode addUser(UserVo uservo) {
        GlobalEnum.ErrorCode errorCode = GlobalEnum.ErrorCode.USER_ADD_FAILED;
        User user = new User();
        user.setUsername(uservo.getUserName());
        user.setPassword(userVo.getPassword());
        user.setBirthday(Converter.localDateToDate(uservo.getBirthday()));
        user.setMobile(uservo.getMobile());
        user.setEnName(uservo.getEnName());
        user.setEmail(uservo.getEmail());
        user.setIsActive(true);
        user.serProfileUrl(uservo.getProfileUrl());
        user.setCreateperson(1);
        user.setUpdateperson(1);
        user.setCreatetime(Converter.localDateTimeToDate(LocalDateTime.now()));
        user.setUpdatetime(Converter.localDateTimeToDate(LocalDateTime.now()));
        userMapper.insert(user);
        return errorCode;
    }
}
